<?php
/**
* The Header for our index file.
*
* @package fructa
* @since fructa 1.0
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo('charset'); ?>">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
	<meta name="author" content="Fructa www.fructacr.com" />
	<title><?php bloginfo('name'); ?><?php wp_title(':'); ?></title>
	<?php wp_head(); ?>
	<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />
	<link rel="stylesheet" type="text/css" media='screen (max-width: 800px)' href="<?php echo get_template_directory_uri(); ?>/css/style-responsive.css" />
	<!--[if lt IE 9]>
      <style>
      	.f-showPhone{
      		display:none!important;
      	}
      	.tab-pane{
      		display:block!important;
      	}
		.navbar{			
			filter: progid:DXImageTransform.Microsoft.Shadow(enabled=false) !important;
			filter: none;
		}
     </style>
     <![endif]-->
 </head>
 <body>
 	<div class="parallax-bg f-hidePhone">
 		<?php
 		$categories = null;
 		$parent_category = get_category_by_slug("products");
 		if (post_is_in_descendant_category($parent_category->cat_ID) ) {
 			$child_category = get_the_category();
 			if($child_category){
 				$categories = get_category($child_category[0]->category_parent);
 			}
 		}else{
 			$categories = get_the_category();
 			if($categories){
 				$categories = $categories[0];
 			}
 		}
 		if($categories!=null){
 			$subcategories = get_categories(array('parent' => $categories->cat_ID, 'hide_empty' => 0));
 			$subarray = array();
 			if($subcategories){
 				foreach($subcategories as $category) {
 					array_push($subarray, $category->cat_ID);
 				}
 			}		
 			if($categories){
 				$the_query = new WP_Query(array('post_type' => 'attachment', 'post_status' => 'inherit', 'category_name' => $categories->slug, 'category__not_in' => $subarray));
 				if ($the_query->have_posts()) {
 					while ($the_query->have_posts()) {
 						$the_query->the_post();
 						$image_attributes = wp_get_attachment_image_src($attachment->ID, 'full');
 						echo '<img src="'.$image_attributes[0].'">';		
 					}
 				}
 				wp_reset_postdata();
 			}
 		}
 		?>
 	</div><!-- end of parallax-->

 	<img class="see-more-arrow f-hidePhone" src="<?php bloginfo('template_url'); ?>/images/see-more.png" alt="Scrool the page to see more"/>

 	<?php
 	$the_query = new WP_Query('name=Scroll for more');
 	if ($the_query->have_posts()) {
 		while ($the_query->have_posts()) {
 			$the_query->the_post();
 			echo get_the_content();
 		}
 	}
 	wp_reset_postdata();
 	?>

 	<div class="f-header">
 		<div class="f-logo-menu container">
 			
 			<div class="navbar">
 				<div class="navbar-inner">
 					<a href="/" class="f-logo brand f-hidePhone"></a>
 					<img src="<?php bloginfo('template_url'); ?>/images/fructa-fruitless.png" class="f-logo-phone f-showPhone" />
 					<span class="f-showPhone menuSing">Menu</span>
 					<button type="button" class="btn btn-navbar collapsed" data-toggle="collapse" data-target=".nav-collapse">
 						<span class="icon-bar"></span>
 						<span class="icon-bar"></span>
 						<span class="icon-bar"></span>
 					</button>
 					<div class="nav-collapse collapse">
 						<?php wp_nav_menu( array( 'theme_location' => 'pages-menu', 'menu_class' => 'nav')); ?>
 						<ul class="f-language">
 							<?php
 							global $q_config;
 							foreach(qtrans_getSortedLanguages() as $language) {
 								?>
 								<li>
 									<a href="<?php echo qtrans_convertURL($url, $language);?>" title="<?php echo $q_config['language_name'][$language]; ?>">
 										<img src="<?php bloginfo('template_url'); ?>/images/<?php echo $q_config['locale'][$language]; ?>_flag.jpg" alt="See this page on <?php echo $q_config['language_name'][$language]; ?>"/>
 									</a>
 								</li>
 								<?php } ?>
 							</ul>
 						</div><!-- nav-collapse -->
 						
 					</div><!-- navbar-inner -->
 				</div><!-- navbar -->


